<!--征求意见列表-->
<template>
  <div>
    <avue-crud :data="opinionData"
               :option="opinionOption"
               :page="opinionPage"
               :table-loading="opinionTableLoading"
               @on-load="getOpinionList"
               @search-change="refreshOpinionChange"
               class="menu-min-height">
      <template slot-scope="scope" slot="menu">
        <div class="menu-title" @click.stop="opinionFeedback(scope.row,scope.index)">
          <i class="iconfont iconview icon-primary"></i>
          <p class="menu-title-text">反馈结果</p>
        </div>
      </template>
    </avue-crud>
    <el-dialog
      title=""
      :visible.sync="dialogVisibleReview"
      width="70%"
      :before-close="handleClosesubmit">
      <h2 style="margin-top: -20px;margin-bottom: -10px;">征求意见详情：</h2>
      <div class="dial">
        <bostech-detail :detail-data="opinionDetailData"></bostech-detail>
      </div>
      <div style="text-align: center;">
          <span slot="footer" class="dialog-footer">
              <el-button @click="dialogVisibleReview = false">关 闭</el-button>
            </span>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import getOpinionDetail from "@/mixins/opinion/getOpinionDetail";
import {getOpinionList} from "@/api/opinion";
export default {
  name: "opinionList",
  mixins: [getOpinionDetail()],
  props: {
    relateId:'',
    type:''
  },
  data(){
    return {
      opinionPage: {
        total: 0, // 总页数
        currentPage: 1, // 当前页数
        pageSize: 10 // 每页显示多少条
      },
      opinionData: [],//审批情况列表
      //审批情况表格类型
      opinionOption: {
        page: true,
        menuWidth: 120,
        addBtn: false,
        editBtn: false,
        addRowBtn: false,
        indexLabel: "序号",
        index: true,
        indexWidth:70,
        cellBtn: false,
        delBtn: false,
        columnBtn: false,
        refreshBtn: false,
        filterBtn: false,
        searchBtn: false,
        keyId: "id",
        column: [
          {
            label: "征集主题",
            prop: "title",
            cell: true,
            formatter: function (row, value, label, column) {
              return '<a style="cursor: pointer;" onclick="detailOpinion(\'' + row.opinionId + '\')">' + value + '</a>';
            },
          },
          {
            label: "截止日期",
            prop: "endDate",
            cell: true
          },
          {
            label: "创建人",
            prop: "createNickname",
            cell: true
          },
        ]
      },
      opinionTableLoading: false,
      // 征求意见列表是否有显示标志
      opinionHaveDataFlag:true,
      // 征求意见详情弹框标志
      dialogVisibleReview:false,
    }
  },
  created(){
    window.detailOpinion = this.detailOpinion
  },
  methods:{
    // 获取征求意见情况 （审批详情相关方法）
    getOpinionList(page,params){
      this.opinionTableLoading = true;
      getOpinionList(Object.assign({
        current: page.currentPage,
        size: page.pageSize,
        relateId: this.relateId,
        type: this.type
      })).then(response => {
        this.opinionData = response.data.data.records;
        this.opinionPage.total = response.data.data.total;
        this.opinionTableLoading = false;
        if(this.opinionData.length>0){
          this.opinionHaveDataFlag = true;
        }else{
          this.opinionHaveDataFlag = false;
        }
        this.$emit('haveDataFlag',this.opinionHaveDataFlag)
      })
    },
    refreshOpinionChange(){
      this.getOpinionList(this.opinionPage)
    },
    // 征求意见详情
    detailOpinion(opinionId){
      this.getDetailData_opinion(opinionId);
      this.dialogVisibleReview = true
    },
    // 反馈结果
    opinionFeedback(row, index) {
      let src = `/feedbackResult/list/${row.opinionId}`;
      this.$router.push({
        path: src,
        query: {
          targetId: row.targetId,
          type:this.type
        }
      })
    },
  }
};
</script>

